

package ebasclient.abstracts.guielements;

import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractListModel;

/**
 *
 * @author Luca Coraci
 */
public class MyListModel<T>  extends AbstractListModel {
    private List<T> list;

    public MyListModel()
    {
        list = new ArrayList<T>();
    }
    public MyListModel(List<T> list) {
        this.list = list;
   }


    public MyListModel<T> add(T element)
    {
        list.add(element);
        fireIntervalAdded(this, 0, list.size());
        return this;
    }

    @Override
    public Object getElementAt(int index) {
        return list.get(index);
    }

    @Override
    public int getSize() {
        return list.size();
    }
    
    public List<T> getList(){
        return list;
    }
}
